package cn.edu.zjut.medlinebackend.common;

import lombok.Data;

import java.io.Serializable;

@Data
public class BaseResponse<T> implements Serializable {
    private static final long serialVersionUID = -5886659356918376529L;
    private int code;
    private T data;
    private String msg;
    private String description;

    public BaseResponse(int code, T data, String msg, String description){
        this.code = code;
        this.data = data;
        this.msg = msg;
        this.description = description;
    }

    public BaseResponse(int code, T data, String msg){
        this(code, data, msg, "");
    }

    public BaseResponse(ErrorCode errorCode){
        this.code = errorCode.getCode();
        this.data = null;
        this.msg = errorCode.getMessage();
        this.description = errorCode.getDescription();
    }
}
